package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.dto.GoodsSalesDTO;
import com.sky.dto.OrdersPageQueryDTO;
import com.sky.entity.Orders;
import com.sky.vo.OrderSubmitVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;

@Mapper
public interface OrderMapper {
    void insert(Orders orders);

    Orders getByNumber(String number);

    void updateByOrderNumber(Orders orders);

    Orders getByOrderId(Long id);

    @Select("select count(status) from orders where status = #{status}")
    Integer getOredrsCountByStatus(Integer status);


    Page<Orders> getOrdersPage(OrdersPageQueryDTO ordersPageQueryDTO);

    @Select("select * from orders where status = #{status} and order_time < #{time} ;")
    List<Orders> getByOrderStatusAndTime(Integer status, LocalDateTime time);

    @Select("select sum(amount) from orders where status = #{status} and order_time between #{begin} and  #{end} ")
    Double sumOfOrders(Map map);

    Integer countByOrders(Map map);




    List<GoodsSalesDTO> getDishTop10(LocalDateTime beginTime, LocalDateTime endTime);
}
